package com.sgb.kjwl.view.widget;

import android.content.Context;
import com.google.android.material.tabs.TabLayout;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sgb.kjwl.R;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;


public class EditPopWindow extends BasePopWindow {

    private TextView okView;
    private TextView resetView;
    private String[] titles = {"批量增加价格", "批量减少价格"};
    private TabLayout tableLayout;
    private LinearLayout reduce_ll;
    private LinearLayout add_ll;

    public EditPopWindow(Context context) {
        super(context, DIR_DOWN_UP);
    }

    @Override
    protected int popLayout() {
        return R.layout.popwindow_company_type;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        tableLayout = holder.getPop().findViewById(R.id.tablayout);
        reduce_ll = holder.getPop().findViewById(R.id.reduce_ll);
        add_ll = holder.getPop().findViewById(R.id.add_ll);
        okView = holder.getPop().findViewById(R.id.ok_view);
        resetView = holder.getPop().findViewById(R.id.reset_view);
        okView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dissMiss();
                if (onResultClick != null) {
                }
            }
        });

        resetView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        initEditView();
    }

    private void initEditView() {
        tableLayout.addTab(tableLayout.newTab().setText("批量增加价格"));
        tableLayout.addTab(tableLayout.newTab().setText("批量减少价格"));
        tableLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                if(tab.getPosition() == 0){
                    add_ll.setVisibility(View.VISIBLE);
                    reduce_ll.setVisibility(View.GONE);
                }else {
                    add_ll.setVisibility(View.GONE);
                    reduce_ll.setVisibility(View.VISIBLE);
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }
}
